import { getCompanyListApi } from '@/services/brand';
import { useEffect, useState } from 'react';

export default () => {
  const [allCompanyList, setAllCompanyList] = useState<any[]>([]);

  const getList = async () => {
    const { rsCode, body } = await getCompanyListApi({
      pageNo: 1,
      pageSize: 3000,
    });
    if (rsCode === '00000000') {
      setAllCompanyList(
        body.list.map((item: any) => ({
          label: item.name,
          value: item.id,
        })),
      );
    }
  };

  useEffect(() => {
    getList();
  }, []);

  return {
    allCompanyList,
    getList,
  };
};
